//
#include<bits/stdc++.h>
using namespace std;
struct car
{
    int d, v, a;
};
int n, m, L, V, T;
struct miao
{
    int l, r;
};
bool cmp(miao x, miao y)
{
    return x.r>y.r;
};
int main()
{

    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        car C[n]; int A[m], rem[L+5], ans=0;miao mark[n];
        for(int i=0; i<n; i++)
            cin>>C[i].d>>C[i].v>>C[i].a;
        memset(rem, 0, sizeof rem);
        for(int i=0; i<m; i++)
        {
            cin>>A[i];
            rem[A[i]]++;
        }
        for(int i=1; i<=L; i++)
            rem[i]=rem[i-1]+rem[i];

        for(int i=0; i<n; i++)
        {
            mark[i].l=mark[i].r=-1;
            if(C[i].a==0)
            {
                if(C[i].v>=V)
                {
                    if(C[i].d==0 || (rem[L]-rem[C[i].d-1])>0)
                        mark[i].l=C[i].d, mark[i].r=L, ans++;
                }
            }
            else if(C[i].a<0)
            {
                if(C[i].v==V)
                {
                    if((C[i].d==0 && rem[0]==0) || C[i].d-C[i-1].d)
                        mark[i].l=C[i].d, mark[i].r=C[i].d, ans++;
                }
                else if(C[i].v>V)
                {
                    float t=(V-C[i].v)/C[i].a*1.000000;
                    float s=(C[i].d+(C[i].v*t+0.5*C[i].a*t*t))*1.000000;
                    int ss=floor(s);
                    if(ss>=0 && ((rem[ss]>0 && C[i].d==0) || (rem[ss]-rem[C[i].d-1]>0)))
                        mark[i].l=C[i].d, mark[i].r=ss, ans++;
                }
            }
            else if(C[i].a>0)
            {
                if(C[i].v>=V)
                {
                    if(C[i].d==0 || (rem[L]-rem[C[i].d-1])>0)
                        mark[i].l=C[i].d, mark[i].r=L, ans++;
                }
                else
                {
                    float t=(V-C[i].v)/C[i].a*1.000000;
                    float s=(C[i].d+(C[i].v*t+0.5*C[i].a*t*t))*1.000000;
                    int ss=ceil(s);
                    if((ss==0 || (rem[L]-rem[ss-1])>0)&& ss<=L)
                        mark[i].l=ss, mark[i].r=L, ans++;
                }
            }
            //cout<<ans<<endl;
        }
        cout<<ans<<" "; if(ans==0)  {cout<<"0"<<endl; continue;}
        sort(mark, mark+n, cmp);
        int ll=mark[0].l, rr=mark[0].r, ans1=1;
        for(int i=1; i<n; i++)
        {
            if(mark[i].l<ll)  ans1++, ll=mark[i].l;
        }
        cout<<ans1<<endl;
    }
    return 0;
}
